package com.example.bootdemo.dao.impl;

import com.example.bootdemo.dao.UserDao;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: gaochao
 * @time: 2020/11/21 16:27
 */
@Component
public class UserDaoImpl implements UserDao {

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;

    public Map<String,String> selectUserByName(String userNm){
        Map<String, Object> param = new HashMap<>();
        param.put("userName", userNm);
        List<Map<String,String>> objects = sqlSessionTemplate.selectList("com.example.bootdemo.pojo.UserMapper.selectUserByName", param);
        if(objects !=null && objects.size()>0){
            return objects.get(0);
        }
        return null;

    }



}
